package com.yuncha.scripture.seeking.demo.leetcode;

import java.util.Random;

/**
 * @author fengjiangtao
 * @version 1.0
 * @desc
 * @date 2025-02-17 11:08:50
 */
public class SortUtil {
    //写一个冒泡排序
    public static void sort(int[] src) {
        for (int i = 0; i < src.length; i++) {
            for (int j = 0; j < src.length - i - 1; j++) {
                if (src[j] > src[j + 1]) {
                    int temp = src[j];
                    src[j] = src[j + 1];
                    src[j + 1] = temp;
                }
            }
        }
    }

    public static void main(String[] args) {
        int[] arr = new int[10];
        for (int i = 0; i < 10; i++) {
            arr[i] = new Random().nextInt(100);
            System.out.println(arr[i]);
        }
        //1、冒泡排序
        SortUtil.sort(arr);

        System.out.println("==========================");
        for (int i = 0; i < 10; i++) {
            System.out.println(arr[i]);
        }

    }
}
